package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.Message;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MessageDTO extends Message implements Converter<Message, MessageDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    private Date endDate;

    private Date startDate;

    @Override
    public void convert2Do(Message message) {
        BeanUtils.copyProperties(this, message);
    }

    @Override
    public MessageDTO convert(Message message) {
        BeanUtils.copyProperties(message, this);
        return this;
    }
}
